<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="/common/common.jspf"%>
<script type="text/javascript" src="${ctx}/js/metals/parts/parts_return_add.js"></script>
<script type="text/javascript">
	$(".selectinfo").change(function(){
		var buyId=$(this).val();
		var that=$(this);
		$.getJSON(rootPath+"/parts/parts_return_choose.shtml","buyId="+buyId,function(data){
				$.each(data, function(i, item){
				  	$("#tbl tr").not(":first").remove();
				  	if(i==0){
				  		that.parent().prev().prev().prev().find("input").val(item.id);
				  		that.parent().prev().prev().find("input").val(item.departmentId);
				  		that.parent().prev().find("input").val(item.supplierId);
						that.parent().next().find("input").val(item.metalsBom.materialCode);
						that.parent().next().next().find("input").val(item.metalsBom.name);
						that.parent().next().next().next().find("input").val(item.metalsBom.specifications);
						that.parent().next().next().next().next().find("input").val(item.metalsBom.unit);
						that.parent().next().next().next().next().next().find("input").val(item.number);
						that.parent().next().next().next().next().next().next().find("input").val(item.price);
						that.parent().next().next().next().next().next().next().next().find("input").val(item.total);
				  	}else{
				  		
				  		R = tbl.insertRow(tbl.rows.length);//新插入的行
						C = R.insertCell(0);
						C.innerHTML = '<input type="text" readonly="readonly" class="form-control" name="id" id="item_no_1_" value="'+item.id+'">';
						C = R.insertCell(1);
						C.innerHTML = '<input type="text" readonly="readonly" class="form-control" name="departmentId" id="item_no_1_" value="'+item.departmentId+'">';
						C = R.insertCell(2);
						C.innerHTML = '<input type="text" readonly="readonly" class="form-control" name="supplierId" id="item_balance_up_1" value="'+item.supplierId+'">'; 
						C = R.insertCell(3);
						C.innerHTML = '<input type="text" readonly="readonly" class="form-control" name="buyId" id="item_balance_down_1" value="'+item.buyId+'">';
						C = R.insertCell(4);
						C.innerHTML = '<input type="text" readonly="readonly" class="form-control" name="materialCode" id="item_balance_down_1" value="'+item.metalsBom.materialCode+'">';
						C = R.insertCell(5);
						C.innerHTML = '<input type="text" readonly="readonly" class="form-control" name="name" id="item_balance_down_1" value="'+item.metalsBom.name+'">';
						C = R.insertCell(6);
						C.innerHTML = '<input type="text" readonly="readonly" class="form-control" name="specifications" id="item_balance_down_1" value="'+item.metalsBom.specifications+'">';
						C = R.insertCell(7);
						C.innerHTML = '<input type="text" readonly="readonly" class="form-control" name="unit" id="item_balance_down_1" value="'+item.metalsBom.unit+'">';
						C = R.insertCell(8);
						C.innerHTML = '<input type="text" readonly="readonly" class="form-control" name="number" id="item_balance_down_1" value="'+item.number+'">';
						C = R.insertCell(9);
						C.innerHTML = '<input type="text" readonly="readonly" class="form-control" name="price" id="item_balance_down_1" value="'+item.price+'">';
						C = R.insertCell(10);
						C.innerHTML = '<input type="text" readonly="readonly" class="form-control" name="total" id="item_balance_down_1" value="'+item.total+'">';
						C = R.insertCell(11);
						C.innerHTML = '<input type="text" class="form-control" name="comment" id="item_balance_down_1" value="">';
						C = R.insertCell(12);
						C.innerHTML = '<input type="text" readonly="readonly" class="form-control" name="" id="item_balance_down_1" value="">';
				  		
				  	}		  	
				}); 					 
		});
	});
</script>
<style type="text/css">
.td {
	width: 7%;
	overflow: hidden;
	height: 15%;
	text-align: center
}

.form-control {
	position: abslute;
	top: 20%;
	right: 20%;
	float: right"
}

.input-text {
	width: 100%;
	height: 100%
}
</style>
</head>
<body>
	<div style='width: 100%;height:300px'>
		<form id="form" name="form" class="form-horizontal" method="post"
			action="${ctx}/parts/parts_return_add.shtml">
			<section class="panel panel-default">
			<table border="1" style="margin: 0 auto;" >
				<tr>
					<td class="td">序号</td>
					<td class="td">部门</td>
					<td class="td">供应商</td>
					<td class="td">采购单号</td>
					<td class="td">物料编码</td>
					<td class="td">名称</td>
					<td class="td">规格型号</td>
					<td class="td">单位</td>
					<td class="td">数量</td>
					<td class="td">单价</td>
					<td class="td">总价</td>
					<td class="td">退货原因</td>
					<td class="td">退货日期</td>
				</tr>
				<tr>
					<tbody id="tbl">
					<td class="td"><input type="text" class="input-text" readonly
						name="id" id="site" value=""></td>
					<td class="td"><input type="text" class="input-text" readonly
						name="departmentId" id="site" value=""></td>					
					<td class="td"><input type="text" class="input-text" readonly
						name="supplierId" id="site" value=""></td>
					<td class="td">
						<select name="buyId" class="form-control selectinfo" >
								<option>选择</option>
								<c:forEach var="key" items="${purchaseRequest }">
									<option value="${key.buyId }">${key.buyId }</option>
								</c:forEach>
						</select>
					</td>
					<td class="td">
						<input type="text" class="input-text" readonly="readonly"
						name="materialCode" id="site" value=""></td>
					<td class="td"><input type="text" class="input-text" readonly="readonly"
						name="name" id="site" value=""></td>
					<td class="td"><input type="text" class="input-text" readonly="readonly"
						name="metalsBomFormMap.specifications" id="site" value=""></td>
					<td class="td"><input type="text" class="input-text" readonly="readonly"
						name="unit" id="site" value=""></td>
					<td class="td"><input type="text" class="input-text" readonly="readonly"
						name="number" id="site" value=""></td>
					<td class="td"><input type="text"class="input-text" name="price" id="site" readonly="readonly"
						value=""></td>
					<td class="td"><input type="text"class="input-text" name="total" id="site" readonly="readonly"
						value=""></td>
					<td class="td"><input type="text"class="input-text" name="comment" id="site" 
						value=""></td>
					<td class="td"><input type="text"class="input-text" name="" id="site" readonly="readonly"
						value=""></td>
					</tbody>	
				</tr>
					
					
										
				<tr>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td">仓管员</td>
					<td class="td">会计</td>
				</tr>
				<tr>
					<td class="td">&nbsp;</td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td">
						<c:forEach var="u" items="${userFormMaps }">
							<c:if test="${u.position_id==27}">
								<input type="text" readonly="readonly" class="form-control" name="remark_1" value="${u.userName}" >
							</c:if>
						</c:forEach>
					</td>
					<td class="td">
						<c:forEach var="u" items="${userFormMaps }">
							<c:if test="${u.position_id==4}">
								<input type="text" readonly="readonly" class="form-control" name="remark_1" value="${u.userName}" >
							</c:if>
						</c:forEach>
					</td>
				</tr>
				<tr>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td">日期</td>
					<td class="td">日期</td>
				</tr>
				<tr>
					<td class="td">&nbsp;</td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td"></td>
					<td class="td">
						<c:forEach var="u" items="${userFormMaps }">
							<c:if test="${u.position_id==27}">
								<input type="text" readonly="readonly" class="form-control" name="remark_1" value="${u.auditTime}" >
							</c:if>
						</c:forEach>
					</td>
					<td class="td">
						<c:forEach var="u" items="${userFormMaps }">
							<c:if test="${u.position_id==4}">
								<input type="text" readonly="readonly" class="form-control" name="remark_1" value="${u.auditTime}" >
							</c:if>
						</c:forEach>
					</td>
				</tr>
			</table>
			<footer class="panel-footer text-right bg-light lter">
				<button type="submit" class="btn btn-success btn-s-xs">提交</button>
			</footer>
			</section>
		</form>
	</div>
</body>
</html>